<?php

if(!defined('IN_AACMS') || !defined('IN_ADMINCP')) {
	exit('Access Denied');
}

loadcache('setting');
$setting = & $_G['setting'];
	
if(submitcheck('settingsubmit')) {

	foreach($_POST as $k=>$v){
		if(is_array($v)) {
			$v = serialize($v);
		}
			
		DB::query("UPDATE ".DB::table('setting')." SET svalue='$v' WHERE skey='$k'");
	}
		
	include_once libfile('function/cache');
	updatecache('setting');
	cpmsg('setting_update_succeed', 'action=setting&operation='.$operation.(!empty($_POST['anchor']) ? '&anchor='.$_POST['anchor'] : ''), 'succeed');
	
}
	
if($operation == 'basic') {
	
	include template('setting_basic', 'admin');
		
} elseif($operation == 'access') {
	
	include template('setting_access', 'admin');
		
} elseif($operation == 'datetime') {
		
	$timezone_lang = cplang('setting_datetime_timezone');
	$timezone_select = "<select name='timeoffset'>";
	foreach($timezone_lang AS $key => $val) {
		$timezone_select .= "<option value='$key' ".($setting['timeoffset'] == $key ? 'selected="selected"' : '').">".cutstr($val, 34, '..')."</option>";
	}
	$timezone_select .= "</select>";
		
	include template('setting_datetime', 'admin');
		
} elseif($operation == 'attach') {
	
	include template('setting_attach', 'admin');
		
} elseif($operation == 'imgwater') {
		
	$watermarkstatuscheckd[$setting['watermarkstatus']] = 'checked=""';
	include template('setting_imgwater', 'admin');
		
}

?>